#pragma once

#include <QImage>
#include <QLayout>
#include <QLabel>
#include <QPixmap>
#include <QPainter>
#include <QPen>
#include <newQLable.h>

#include "baseWidget.h"
#include "singleton.h"
#include "Json.h"

#define COLORSCALAR 0.64
#define SCALAR 0.5
#define SCALARMAX 2
#define CROSSSIZE 8


class Show2D : public BaseWidget
{
public:
    Show2D(QWidget * parent = nullptr);
    ~Show2D();

    void __setData(std::shared_ptr<LvMat> & src, int min, int max);
    void __render();

    void setBlackBG(bool src);

    void setFullScreen(bool isFull) {m_isFullScreen = isFull;}

    void setCallBack(std::function<void(void)> && cb)
    {
        m_imgLabel->setCallBack(std::forward<std::function<void(void)>>(cb));
    }

    void drawpos(int row, int col);

    void __saveData(const std::string & filePath);

private:
    void HSVtoRGB(uint8_t *r, uint8_t *g, uint8_t *b, uint16_t h, uint16_t s = 100, uint16_t v = 100);


private:
    QImage *                        m_img           = nullptr;
    NewQLabel *                     m_imgLabel      = nullptr;
    QLabel *                        m_dataLabel     = nullptr;
    bool                            m_blackBGEnable = false;
    bool                            m_isFullScreen  = false;

    bool                            m_isSaveFlag    = false;
    std::string                     m_filePath;

    float                           m_imgScalar     = 0.5;

    QWidget *                       m_parent        = nullptr;
};




